<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加角色</title>
</head>
<body>

<form class="layui-form" lay-filter="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label"><text title="必填项" style="color:red;">*</text>技能名称</label>
                    <div class="layui-input-block">
                        <input type="text"  name="name" lay-verify="required" autocomplete="off" placeholder="请输入技能名称" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">角色</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="role_id"
                             data-sourceType="route"
                             data-source="/admin.yys.role/index"
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="true"
                             data-layVerify="required"
                             data-direction="down"
                        ></div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">图示</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="ico"
                             data-accept="image"
                             data-type="ali-oss"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label"><text style="color:red;">*</text>技能分类</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="category"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'变身前',value:'1'},{name:'变身后',value:'2'}]"
                             data-layVerify="required"
                        ></div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label"><text title="必填项" style="color:red;">*</text>技能类型</label>
                    <div class="layui-input-block">
                        <input type="text" name="type" lay-verify="required" autocomplete="off" placeholder="请输入技能类型" class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label"><text title="必填项" style="color:red;">*</text>技能消耗</label>
                    <div class="layui-input-block">
                        <input type="number" name="cost" lay-verify="required" autocomplete="off" placeholder="请输入技能消耗" class="layui-input">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label" title="技能效果"><text title="必填项" style="color:red;">*</text>技能效果</label>
                    <div class="layui-input-block">
                        <textarea name="effect" placeholder="请输入技能效果" class="layui-textarea" lay-verify="required"></textarea>
                    </div>
                </div>


                <blockquote class="layui-elem-quote">升级效果</blockquote>
                <div class="layui-form-item">
                    <table class="layui-table" style="margin: 0;" lay-skin="line">
                        <colgroup>
                            <col width="90%">
                            <col width="10%">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>效果</th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody class="tableDnd">
                        <tr>
                            <td style="padding: 4px 15px;"><input class="layui-input" type="text" name="grade[]" value="" /></td>
                            <td style="padding: 4px 15px;">
                                <a href="javascript:void(0);" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-delete delArrayItem" layer-tips="删除" title="删除"></a>
                            </td>
                        </tr>
                        <tr class='nodrop nodrag'>
                            <td colspan="4" style="padding: 4px 15px;">
                                <a href="javascript:void(0);" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-1 addArrayItem" title="追加">追加</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'],function(){
        layui.form.on('submit(add)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.yys.skill/add',
                data : data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>